package com.wei.czz.common.dto.annex;

import com.wei.czz.common.enums.CommonEnum;
import com.wei.czz.common.enums.annex.AnnexClassifyEnum;
import com.wei.czz.common.tool.BaseEntity;
import com.wei.czz.framework.annex.entity.AnnexPreEntity;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2024-01-19 11:58:22
 * className: AnnexPreDto
 * version: 1.0
 * description:
 */
@Getter
@Setter
public class AnnexPreDto extends BaseEntity {

    /**
     * 主键
     */
    private String id;

    /**
     * 分类
     */
    private Integer classify;

    /**
     * 分类名称
     */
    private String classifyName;

    /**
     * 版本号
     */
    private Integer version;

    /**
     * 状态[0-启用 1-编辑 2-停用]
     */
    private Integer status;

    /**
     * 状态名称
     */
    private String statusName;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 创建用户
     */
    private String createUser;

    /**
     * 附件动态配置前置对象映射
     * @param annexPre 附件动态配置前置对象
     * @return 映射结果
     */
    public static AnnexPreDto map(AnnexPreEntity annexPre) {
        AnnexPreDto annexPreDto = new AnnexPreDto();
        annexPreDto.id = annexPre.getId().toString();
        annexPreDto.classify = annexPre.getClassify();
        annexPreDto.classifyName = AnnexClassifyEnum.getName(annexPre.getClassify());
        annexPreDto.version = annexPre.getVersion();
        annexPreDto.status = annexPre.getStatus();
        if (CommonEnum.ZERO.getValue().equals(annexPre.getStatus())) {
            annexPreDto.statusName = "启用";
        }
        if (CommonEnum.ONE.getValue().equals(annexPre.getStatus())) {
            annexPreDto.statusName = "编辑";
        }
        if (CommonEnum.TWO.getValue().equals(annexPre.getStatus())) {
            annexPreDto.statusName = "停用";
        }
        annexPreDto.createTime = annexPre.getCreateTime();
        annexPreDto.createUser = annexPre.getCreateUser();

        return annexPreDto;
    }

}
